#nullable disable
namespace Crux.Core.Data;
/// <summary>
/// UniqueIdentifierGenerator
/// </summary>
public class UniqueIdentifierGenerator
    : IUniqueIdentifierGenerator
{
    #region implements IUniqueIdentifierGenerator
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public T Generate<T>() => typeof(T) switch
    {
        var x when x == typeof(Guid) => (T)Convert.ChangeType(Guid.NewGuid(), typeof(T)),
        var x when x == typeof(string) => (T)Convert.ChangeType(StringIdentifier.GenerateNewId().ToString(), typeof(T)),
        var x when x == typeof(long) => (T)Convert.ChangeType(LongIdentifier.GenerateNewId(), typeof(T)),
        _ => default
    };
    #endregion implements IUniqueIdentifierGenerator
}